<?php
include("../lib/item.lib");
include("../lib/db.lib");
include("../lib/std.lib");


$cat_id=param("cat_id");
$shop_id=param("shop_id");

$key=param("key");
$title="search $key";
$pd_list=search_author($key);
$item_num=count($pd_list);


$start=param("start");
if($start<=0) $start=1;
$step=100;
$pre_start=$start-$step;

if($pre_start>0){
   $p_str= "<a href=\"p_cat_pd_list.php?start=$pre_start&cat_id=$cat_id\">Previous $step </a>&nbsp;";
}
if($item_num >=$start+$step){
    $next_start=$start+$step;
    $n_str= "<a href=\"p_cat_pd_list.php?start=$next_start&cat_id=$cat_id\">Next $step</a> &nbsp;(Total $item_num )";
}

?>
<html>


<HEAD><TITLE>Catalog display</TITLE>
<META NAME='KEYWORDS' CONTENT=''/>
<LINK REL="stylesheet" HREF="wiki.css">
<META NAME="description" content="">
<meta http-equiv="Content-Style-Type"  content="text/css">
<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="Content-Type"   content="text/html; charset=GB2312">
</HEAD>
<body>
<?php include("header.php");?>

<h2>Item in catagory: <? echo $title; ?> (only top 1000)</h2>
<div align="right">
<?php 
home();
?>
</div>
<?php 
echo $p_str."&nbsp;". $n_str;
?>
<table border="0" width="90%">
<?php
$list=$pd_list;
$i=0;

foreach($list as $key=>$val){
//	if(!$val['id']){break;}

	$i++;

	if($i>=$start+$step) break;
	if($i<$start) continue;

	$p_id= $val['id'];

	if($i>1){
	$move_up_str="<a href=\"p_cat_pd_list.php?switch=1&cat_id=$cat_id&id_1=$p_id&id_2=$pre_p_id\">(Move Up)</a>";
	}	
	$pre_p_id=$p_id;

	echo "<tr valign=\"top\">\n";
	echo "<td width=\"4\"> $i. </td>\n<td >";
	echo "<a href='${base_url}xys/$p_id'>" . $val['title']. "</a> <span class='author'>(" .$val['author']." ".$val['date'].")</a></td>\n";
	echo "<td width=\"150\"> <a href=\"p_product_del_confirm.php?pd_id=$p_id\">Del</a> &nbsp; <a href=\"p_product_update.php?pd_id=$p_id\">Update</a> &nbsp;  </td>\n";
//	echo "<td width=\"54\"> $move_up_str </td>\n";
	echo "</tr>\n";
}
?>
</table>
<br>

<?php 
echo $p_str."&nbsp;".$n_str;
?>


<div align="right"><a href="p_add_product.php?cat_id=<? echo $cat_id;?>">Add more items</a></div>

<?php include("copyright.php");?>

</body>
</html>
